﻿/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework - CNR Framework Section
 * Version 2.10
 * 
 * CNR Validation Error Event Arguments Class
 *      Provides an event arguments base class for CNR validation error events.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
using System;
using Adaptive.Foundation;

namespace Adaptive.Foundation.Network.Cnr
{
    /// <summary>
    /// Provides an event arguments base class for CNR validation error events.
    /// </summary>
    /// <remarks>
    /// This class is intended to act as the base definition for all validation
    /// error or failure events used in the CNR framework.
    /// </remarks>
    public class CnrValidationErrorEventArgs : System.EventArgs
    {
        /*--------------------------------------------------------------------------------
         * Private Member Declarations
         *------------------------------------------------------------------------------*/
        #region Private Member Declarations

        private CnrValidationRuleBase _rule;
        private CnrValidationActionBase _action;
        private string _data;
        private bool _ignoreError;

        #endregion

        /*--------------------------------------------------------------------------------
         * Constructor / Dispose / Destructor Methods
         *------------------------------------------------------------------------------*/
        #region Constructor / Dispose / Destructor Methods
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <remarks>
        /// This is the default constructor.
        /// </remarks>
        public CnrValidationErrorEventArgs()
            : base()
        {
            _data = null;
            _rule = null;
            _action = null;
            _ignoreError = false;
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="rule">
        /// A <see cref="CnrValidationRuleBase"/> rule implementation that failed.
        /// </param>
        public CnrValidationErrorEventArgs(CnrValidationRuleBase rule)
        {
            _data = null;
            _rule = rule;
            _action = null;
            _ignoreError = false;
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="rule">
        /// A <see cref="CnrValidationRuleBase"/> rule implementation that failed.
        /// </param>
        /// <param name="originalData">
        /// A string containing the erroneous data.
        /// </param>
        public CnrValidationErrorEventArgs(CnrValidationRuleBase rule, string originalData)
        {
            _data = originalData;
            _rule = rule;
            _action = null;
            _ignoreError = false;
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="action">
        /// A <see cref="CnrValidationActionBase"/> that was being performed when the rule failed.
        /// </param>
        /// <param name="rule">
        /// A <see cref="CnrValidationRuleBase"/> rule implementation that failed.
        /// </param>
        public CnrValidationErrorEventArgs(CnrValidationActionBase action, CnrValidationRuleBase rule)
        {
            _data = null;
            _rule = rule;
            _action = action;
            _ignoreError = false;
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="action">
        /// The validation action that was being performed.
        /// </param>
        /// <param name="rule">
        /// A <see cref="CnrValidationRuleBase"/> rule implementation that failed.
        /// </param>
        /// <param name="originalData">
        /// A string containing the erroneous data.
        /// </param>
        public CnrValidationErrorEventArgs(CnrValidationActionBase action, CnrValidationRuleBase rule, string originalData)
        {
            _data = originalData;
            _rule = rule;
            _action = action;
            _ignoreError = false;
        }
        /// <summary>
        /// Class destructor.
        /// </summary>
        ~CnrValidationErrorEventArgs()
        {
            _rule = null;
            _data = null;
            _action = null;
        }
        #endregion

        /*--------------------------------------------------------------------------------
         * Public Properties
         *------------------------------------------------------------------------------*/
        #region Public Properties
        /// <summary>
        /// Gets the reference to the Cnr Rule instance that was violated.
        /// </summary>
        /// <value>
        /// A <see cref="CnrValidationRuleBase"/> instance, or <b>null</b>.
        /// </value>
        public CnrValidationRuleBase Rule
        {
            get { return _rule; }
        }
        /// <summary>
        /// Gets the reference to the Cnr Validation action that was being performed.
        /// </summary>
        /// <value>
        /// A <see cref="CnrValidationActionBase"/> instance, or <b>null</b>.
        /// </value>
        public CnrValidationActionBase Action
        {
            get { return _action; }
        }
        /// <summary>
        /// Gets or sets the data that caused the error.
        /// </summary>
        /// <value>
        /// The erroneous data, or data modified by the event handler.
        /// </value>
        public string Data
        {
            get { return _data; }
            set { _data = value; }
        }
        /// <summary>
        /// Gets or sets a value indicating whether to ignore the validation error.
        /// </summary>
        /// <value>
        /// <b>true</b> to ignore the error when the event completes; otherwise, <b>false</b>.
        /// </value>
        public bool IgnoreError
        {
            get { return _ignoreError; }
            set { _ignoreError = value; }
        }
        #endregion
    }
}